package com.ylxn.codeTop;

import java.util.LinkedList;
import java.util.Stack;

/**
 * @author cenghaile
 * @version 1.0.0
 * @titel CQueue
 * @description <剑指 Offer 09. 用两个栈实现队列>
 * @crete 2023/6/1 09:12
 */
public class CQueue {

    LinkedList<Integer> A, B;

    public CQueue() {
        A = new LinkedList<>();
        B = new LinkedList<>();
    }

    public void appendTail(int value) {
        A.addLast(value);
    }

    public int deleteHead() {
        if (!B.isEmpty())
            B.removeLast();
        if (A.isEmpty()) return -1;
        while (!A.isEmpty())
            B.addLast(A.removeLast());
        return B.removeLast();
    }
}
